/**
 * Copyright (c) 2013 Axa Holding Belgium, SA. All rights reserved.
 * This software is the confidential and proprietary information of the AXA Group.
 */
package chabernac.gravidroid.model;

import junit.framework.TestCase;

public class StructureTest extends TestCase {
    public void testRectangleStructureIntersects() {
        Structure theStructure = StructureFactory.createRectangle( new Vector( 0, 0 ), 10, 2, 0 );

        assertEquals( theStructure.getLinearMasses().get( 0 ),
                      theStructure.getIntersectingLinearMass( new Mass().setLocation( new Vector( 7, 1 ) ) ).linearMass );
        assertEquals( theStructure.getLinearMasses().get( 2 ),
                      theStructure.getIntersectingLinearMass( new Mass().setLocation( new Vector( 7, -1 ) ) ).linearMass );
        assertEquals( theStructure.getLinearMasses().get( 1 ),
                      theStructure.getIntersectingLinearMass( new Mass().setLocation( new Vector( -4, 0 ) ) ).linearMass );

        assertTrue( theStructure.getIntersectingLinearMass( new Mass().setLocation( new Vector( 7, 1 ) ) ).distance != 0 );
        assertTrue( theStructure.getIntersectingLinearMass( new Mass().setLocation( new Vector( 7, -1 ) ) ).distance != 0 );
        assertTrue( theStructure.getIntersectingLinearMass( new Mass().setLocation( new Vector( -4, 0 ) ) ).distance != 0 );

        assertNull( theStructure.getIntersectingLinearMass( new Mass().setLocation( new Vector( 11, 0 ) ) ) );
        assertNull( theStructure.getIntersectingLinearMass( new Mass().setLocation( new Vector( -11, 0 ) ) ) );
        assertNull( theStructure.getIntersectingLinearMass( new Mass().setLocation( new Vector( 0, 11 ) ) ) );
        assertNull( theStructure.getIntersectingLinearMass( new Mass().setLocation( new Vector( 0, -11 ) ) ) );
        assertNull( theStructure.getIntersectingLinearMass( new Mass().setLocation( new Vector( -11, -11 ) ) ) );
        assertNull( theStructure.getIntersectingLinearMass( new Mass().setLocation( new Vector( 11, 11 ) ) ) );
        assertNull( theStructure.getIntersectingLinearMass( new Mass().setLocation( new Vector( 11, -11 ) ) ) );
        assertNull( theStructure.getIntersectingLinearMass( new Mass().setLocation( new Vector( -11, 11 ) ) ) );

    }
}
